#include "Top10Manager.h"


Top10Manager::Top10Manager(void)
{
}


void Top10Manager::Update( PipeMessage* _msg, bool _destroyMsg )
{
	mTop.clear();

	TopMessage* msg = reinterpret_cast<TopMessage*>(_msg);

	for (int i = 0; i < 10; i++)
	{
		const TopMessage::TopElement tmpElem = msg->Data(i);
		if (!tmpElem.isSet)
			break;

		mTop.push_back(tmpElem);
	}

	if( _destroyMsg )
		delete _msg;
}

const TopMessage::TopElement& Top10Manager::GetElementByUsername( string _username )
{
	static TopMessage::TopElement garbage = { "N/A", 0, 0, 0};

	for(vector<TopMessage::TopElement>::iterator it = mTop.begin(); it != mTop.end(); it++)
		if(_username == it->username)
			return *it;

	return garbage;
}
